// 发送ajax请求

import config from './config'

export default (url, data = {}, method = 'GET') => {
//1. new Promise 初始化promise实例的状态为pending
  return new Promise((resolve, reject) => {
    //http: localhost:3000/banner
    wx.request({
      url: config.host + url,
      data,
      method,
      success: (res) => {
        console.log(res)
        resolve(res.data)
      },
      fail: (err) => {
        console.log('请求失败', err)
        reject(res.err)
      }
    })




  })


}